<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/4
 * Time: 14:09
 */
namespace Collection\Controller;
use Think\Controller;

class CollectionController extends Controller {

    public function collectionlist(){
        $start = I('start');
        $end = I('end');
        $pname = I('pname');
        $srclist = I('srclist');
        if($start != ""){
            $map['createAt'] = array('gt',strtotime($start)*1000);
        }
        if($end != ""){
            $map['createAt'] = array('lt',strtotime($end)*1000);
        }
        if($end != ""&&$start != ""){
            $map['createAt'] = array('between',array(strtotime($start)*1000,strtotime($end)*1000));
        }
        if($pname != ""){
            $map['title'] = array('like',"%".$pname."%");
        }
        if($srclist != ""){
            $map['src'] = array('in',$srclist);
        }
        $goods = D('Fruitdata')->where($map)->order('title desc,createAt desc')->select();
        for($i=0;$i<count($goods);$i++){
            $goods[$i]['createAt']=substr($goods[$i]['createAt'],0,10);
        }
        $srcs = D('Fruitdata')->group('src')->getField('src',true);
        $this->assign('_list',$goods);
        $this->srcs=$srcs;
        $this->display();


    }

}